﻿<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>行政区划管理</title>
	<jsp:include page="/resources/inc/head.jsp" flush="true"/>
</head>
<body>
<div class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-3" id="areaShow"></div>
                    <div class="col-sm-9">
                        <!-- Example Events -->
                         <div class="example-wrap">
                            <div class="example">
                                <div class="btn-group hidden-xs mail-tools tooltip-demo" id="toolbar" role="group">
                                    <shiro:hasPermission name="upms:area:create"><button class="btn btn-white btn-sm" onclick="createAction()" title=""><i  class="glyphicon glyphicon-plus"></i>  新增组织</button></shiro:hasPermission>
                                    <shiro:hasPermission name="upms:area:update"><button class="btn btn-white btn-sm" onclick="updateAction()" title=""><i  class="glyphicon glyphicon-pencil"></i>  编辑组织</button></shiro:hasPermission>
                                    <shiro:hasPermission name="upms:area:delete"><button class="btn btn-white btn-sm" onclick="deleteAction()" title=""><i  class="glyphicon glyphicon-remove"></i>  删除组织</button></shiro:hasPermission>
                                </div>
                                        <form>
                                            <input type="hidden" id="parentCode" />
                                        </form>
                                <table id="table" data-height="400" data-mobile-responsive="true"></table>
                            </div>
                        </div>
                        <!-- End Example Events -->
                    </div>
                </div>
            </div>
        </div>
        <!-- End Panel Other -->
    </div>
</div>
<jsp:include page="/resources/inc/footer.jsp" flush="true"/>
<script></script>
<script>
var $table = $('#table');
$(function() {
    aeye_area_display($('#areaShow'),onSelect,null,null);
    // bootstrap table初始化
    $table.bootstrapTable({
        url: '${basePath}/manage/area/list',
        height: getHeight(),
        striped: true,
        search: true,
        searchOnEnterKey:true,
        trimOnSearch:true,
        showRefresh: true,
        showColumns: true,
        minimumCountColumns: 2,
        detailView: false,
        pagination: true,
        paginationLoop: false,
        sidePagination: 'server',
        silentSort: false,
        smartDisplay: false,
        escape: true,
        idField: 'id',
        maintainSelected: true,
        toolbar: '#toolbar',
        queryParams:function(params){
             params['parentCode'] = $("#parentCode").val();
             return params;
        },
        columns: [
            {field: 'id', title: '区划编码', sortable: true, align: 'center'},
            {field: 'name', title: '区划名称'},
            {field: 'level', title: '区划级别'},
            {field: 'description', title: '区划描述'},
            {field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
        ]
    });
});

function onSelect(areaCode){
    $("#parentCode").val(areaCode);
    $table.bootstrapTable('refresh');
}
// 格式化操作按钮
function actionFormatter(value, row, index) {
    return [
		'<a class="update" href="javascript:;" onclick="updateAction('+row.organizationId+')" data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>　',
		'<a class="delete" href="javascript:;" onclick="deleteAction('+row.organizationId+')" data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>'
    ].join('');
}
</script>
</body>
</html>